import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';
import 'package:get/get.dart';

import '../../tool/assets.dart';

class MyColorController extends ColorController {
  RxBool isOn = false.obs;
  RxList<String> nameList = ['ANIMATION', 'COLOR CYCLE'].obs;
  RxList<bool> nameStates = [false, false].obs;
  RxList<String> colorList =
      [assets.white, assets.red, assets.yellow, assets.green, assets.lightblue, assets.blue, assets.pink].obs;
  RxList<int> hexList = [0xFFFFFFFF, 0xFFFF0000, 0xFFFFFF00, 0xFF00FF00, 0xFF00FFFF, 0xFF0000FF, 0xFFFF00FF].obs;

  void updateIson() {
    isOn.value = !isOn.value;
    SendData.send(tag: 'RGB_TURN', data1: isOn.value ? [0x00] : [0x01]);
  }

  void updateSwith(int index, bool ison) {
    if (!isOn.value) return;
    nameStates[index] = ison;
    nameStates[nameStates.length - index - 1] = !ison;
    int model = index == 0 && ison ? 0x00 : 0x01;
    SendData.send(tag: 'RGB_MODEL', data1: [model]);
    update();
  }

  void udpateColor(List<int> color) {
    SendData.send(tag: 'RGB_COLOR', data1: color);
  }
}
